const express = require('express');
const router = express.Router();
const payController = require('../controllers/payController');
const { authenticate } = require('../middleware/authMiddleware');

// 添加路由日志中间件
router.use((req, res, next) => {
  console.log(`[支付路由] ${req.method} ${req.originalUrl}`);
  next();
});

// 微信支付接口 - 模拟（无需认证方便测试）
router.post('/wechat/create', authenticate, payController.createWechatPayment);

// 微信支付回调 - 模拟
router.post('/wechat/callback', payController.wechatPaymentCallback);

// 余额支付接口
router.post('/balance', authenticate, payController.balancePayment);

// 支付结果查询
router.get('/result/:orderId', authenticate, payController.getPaymentResult);

module.exports = router;